package com.kbt.listener;

import android.app.Activity;
import android.content.Intent;
import android.view.View;

/**
 * @author zhgk
 * @package: com.kbt.listener
 * @TODO:重写事件监听器，用于监听返回按钮单击事件
 * @data: 2015/8/10 16:44
 * @version: V1.0
 */
public class ReturnBtnOnClickListener implements View.OnClickListener {
    //定义要转向的目标Activity
    private Class returnToActivity;
    //定认当前所在的Acitivity
    private Activity nowActivity;

    public ReturnBtnOnClickListener(Activity nowActivity,Class returnToActivity){
        this.returnToActivity = returnToActivity;
        this.nowActivity = nowActivity;
    }

    @Override
    public void onClick(View v) {
        Intent intent = new Intent(nowActivity, returnToActivity);
        nowActivity.startActivity(intent);
        nowActivity.finish();
    }
}
